<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title>清除浮动</title>
		<style type="text/css">
			.father {
				border: 1px solid red;
				/* overflow: hidden; */
				/* 可以清除浮动 */
			}

			.damao {
				width: 100px;
				height: 100px;
				background-color: pink;
				float: left;
			}

			.ermao {
				width: 150px;
				height: 100px;
				background-color: purple;
				float: left;
			}

			.xiaomi {
				width: 300px;
				height: 120px;
				background-color: black;
			}

			/*使用after伪元素清除浮动的方法*/
			.clearfix:after {
				content: ".";
				display: block;
				/* 转换为块级元素 */
				height: 0;
				/* 高度为0 */
				visibility: hidden;
				/* 隐藏盒子 */
				clear: both;
				/* 清除浮动 */
			}

			.clearfix:before,
			.clearfix:after {
				content: "";
				display: table;
			}

			.clearfix:after {
				clear: both;
			}

			.clearfix {
				*zoom: 1;
			}
		</style>
	</head>
	<div class="father clearfix">
		<div class="damao"></div>
		<div class="ermao"></div>
	</div>
	<div class="xiaomi"></div>
	</body>
</html>
